import React, { useState, useEffect } from "react";
import { connect, NavLink, useSelectedRoutes } from "umi";
import "./index.less";
const TabsPage = (props) => {
  const { dispatch, appConfig } = props;
  const routes = useSelectedRoutes();
  const lastRoute = routes.at(-1);
  // 设置tans
  const setTabs = (val) => {
    dispatch({
      type: "appConfig/setTabsList",
      payload: val,
    });
  };

  useEffect(() => {
    console.log(lastRoute.route);
  }, []);

  return (
    <ul className="tabsBox">
      {appConfig.tabsList ||
        [].map((t, ind) => {
          return (
            <li key={ind}>
              <NavLink
                to={t.path}
                style={({ isActive }) => (isActive ? { color: "#2f77f8" } : { color: "#000" })}
              >
                {t.label}
              </NavLink>
            </li>
          );
        })}
    </ul>
  );
};
export default connect((state) => ({
  appConfig: state.appConfig,
}))(TabsPage);
